module.exports = function ($scope, $modalInstance, $resource, $modal, item, flag, toaster){
    

    /* 分页
     * ========================================= */
    $scope.maxSize = 5;             //最多显示多少个按钮
    $scope.bigCurrentPage = 1;      //当前页码
    $scope.itemsPerPage = 200         //每页显示几条
    $scope.findarealist3 = function (){
        
        var para = {
            'path': '3',
            'pageNo':$scope.bigCurrentPage, 
            'pageSize':$scope.itemsPerPage,

        }
        console.log(para)
        $resource('/api/as/ic/createcity/findAreaList', {}, {}).save(para, function(res){
            if(res.errcode === 0){
                $scope.arealist3 = res.data.results;
            }else{
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }

    init();
    function init(){
        $scope.url =  flag ?  '/api/as/ic/createcity/insertGrid' : '/api/as/ic/createcity/updateGrid'; 
        console.log(1)
        $scope.arealist3 = {};
        $scope.findarealist3();
        console.log(item)
        $scope.rulesinfo = flag ? {'flag': true} : angular.copy(item);
 
    }
    //保存
    $scope.save = function (){
       console.log($scope.rulesinfo.area_code)
        $resource( $scope.url , {}, {}).save($scope.rulesinfo, function(res){
            if(res.errcode === 0){
                toaster.success({title: '', body: '保存成功'});
                $modalInstance.close();
            }else{
                toaster.error({title: '', body: res.errmsg});
            }
        });
    }

     
    //取消
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    }


   
};